//
//  StatusCellBottom.swift
//  weibo1990
//
//  Created by 曹晓龙 on 15/10/19.
//  Copyright © 2015年 曹晓龙. All rights reserved.
//

import UIKit

class StatusCellBottom: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
        
        backgroundColor = UIColor(white: 0.85, alpha: 1.0)
    }

    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    //MARK: -懒加载
    
    private lazy var retWeetedBtn:UIButton = UIButton(title: " 转发", imageName: "timeline_icon_retweet")
    private lazy var commentBtn:UIButton = UIButton(title: " 评论", imageName: "timeline_icon_comment")
    private lazy var likeBtn:UIButton = UIButton(title: " 赞", imageName: "timeline_icon_unlike")

}

// MARK: - 设置UI界面
extension StatusCellBottom {
    
    ///  设置UI界面
    private func setupUI(){
        
        //添加控键
        addSubview(retWeetedBtn)
        addSubview(commentBtn)
        addSubview(likeBtn)
        
        // 自动布局
        //转发
        retWeetedBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
        
        //评论
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retWeetedBtn.snp_right)
            make.top.equalTo(retWeetedBtn.snp_top)
            make.bottom.equalTo(retWeetedBtn.snp_bottom)
            make.width.equalTo(retWeetedBtn.snp_width)
        }
        
        //赞
        likeBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.top.equalTo(commentBtn.snp_top)
            make.bottom.equalTo(commentBtn.snp_bottom)
            make.width.equalTo(commentBtn.snp_width)
            
            make.right.equalTo(self.snp_right)
        }
        
        // 添加分割线
        
        let sep1 = sepVIew()
        let sep2 = sepVIew()
        addSubview(sep1)
        addSubview(sep2)
        
        let width:CGFloat = 0.5
        let scale = 0.4
        
        sep1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(retWeetedBtn.snp_right)
            make.centerY.equalTo(retWeetedBtn.snp_centerY)
            make.width.equalTo(width)
            make.height.equalTo(retWeetedBtn.snp_height).multipliedBy(scale)
        }
        sep2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(commentBtn.snp_centerY)
            make.width.equalTo(width)
            make.height.equalTo(retWeetedBtn.snp_height).multipliedBy(scale)
        }
        
    }
    
    ///  添加分割线
    ///
    ///  - returns: 分割线视图
    private func sepVIew()->UIView {
     
        let v = UIView()
        
        v.backgroundColor = UIColor.lightGrayColor()
        
        return v
    }
}